import com.gt.Service.engineDAO;
import com.gt.dao.Service.impl.engineDAOImpl;
import com.gt.vehicleModel.engine;
import com.gt.vehicleModel.engineExample;
import com.gt.vehicleModel.engineExample.Criteria;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
import java.io.*;
import java.sql.SQLException;
import java.util.*;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class IbatisInsertion {
	public static void main(String[] args) throws IOException, SQLException {
//		Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
//		SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
		// Inserting one record in contacts
		System.out
				.println("*-------------- Inserting information in Contact Table -----------*");
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("ApplicationContext.xml");
		engineDAO cdimpl = (engineDAO) ctx.getBean("engineDAO");
		
		engineExample ce= new engineExample();
		Criteria cr =ce.createCriteria();
		cr.andEnginenoEqualTo(2);
		List<engine> ret= cdimpl.selectengineByExample(ce);
		
		System.out.println(ret.get(0).getEnginemodel());
		
		
//		Users contact = new Users("Ganesh", "tiwari", "gtiwari333@gmail.com",
//				"Nepal");
//		sqlMap.insert("Users.insert", contact);
//		System.out.println("|Record Inserted Successfully ");
//		System.out.println("All Contacts");
//		List<Users> contacts = (List<Users>) sqlMap.queryForList(
//				"Users.getAll", null);
//		Users contactall = new Users();
//		for (Users c : contacts) {
//			System.out.print("  " + c.getId());
//			System.out.print("  " + c.getFirstName());
//			System.out.print("  " + c.getLastName());
//			System.out.print("  " + c.getEmail());
//			System.out.print("  " + c.getAddress());
//
//			contact = c;
//			System.out.println("");
//		}
//		System.out
//				.println("================================================================");
	}
}
